﻿'******************************************************
'******************************************************
'Application Title: Google Widget Editor
'version: 1.0
'Date: 01-02-2008
'Requirements: win2k or later
'Author: Andrew Pye
'Author Email: StretchMasterP@googlemail.com
'License: Released under GNU GENERAL PUBLIC LICENSE v3
'ToDo:
'Changes:Imports System.Text
'******************************************************
'******************************************************

Imports System.ComponentModel

''' <summary>
''' 
''' </summary>
''' <remarks></remarks>
Public Class EnumValue
    Implements IObjectName

#Region "Fields"
    Private _Name As String = String.Empty
    Private _value As String = String.Empty
    Private _display_value As String = String.Empty
    Private _Parent As Enums_Collection = Nothing
#End Region
#Region "Properties"

    <DefaultValueAttribute(""), _
    Browsable(False), CategoryAttribute("Misc"), _
    DescriptionAttribute("Is this require lib optional")> _
     Protected ReadOnly Property Parent() As Object Implements IObjectName.Parent
        Get
            Return _Parent
        End Get
    End Property
    <CategoryAttribute("Misc"), DescriptionAttribute("Enum Value")> _
    Public Property Value() As String
        Get
            Return _value
        End Get
        Set(ByVal value As String)
            _value = value
            Me.SetDirty()
        End Set
    End Property
    <CategoryAttribute("Misc"), DescriptionAttribute("Display Value")> _
    Public Property Display_value() As String
        Get
            Return _display_value
        End Get
        Set(ByVal value As String)
            _display_value = value
            Me.SetDirty()
        End Set
    End Property
    <BrowsableAttribute(False)> _
    Public ReadOnly Property ObjectName() As String Implements IObjectName.ObjectName
        Get
            Return Me.Display_value
        End Get
    End Property
#End Region
#Region "Constructor"
    Public Sub New()

    End Sub
    Public Sub New(ByVal display_value As String, ByVal value As String)
        Me.Display_value = display_value
        Me.Value = value
    End Sub

    Protected Overrides Sub Finalize()
        MyBase.Finalize()
    End Sub
#End Region
#Region "Methods"
    Public Sub SetDirty()
        If Me.Parent IsNot Nothing Then Me.Parent.SetDirty()
    End Sub
    Public Sub SetParent(ByVal o_Parent As Object) Implements IObjectName.SetParent
        Me._Parent = o_Parent
    End Sub
#End Region

End Class

''' <summary>
''' Collection of Enums
''' </summary>
''' <remarks></remarks>
Public Class Enums_Collection
    Inherits ObjectModel.KeyedCollection(Of String, EnumValue)
    Implements IObjectName
#Region "Fields"
    Private _Parent As UserPref = Nothing
    Private _IsDirty As Boolean = False
#End Region
#Region "Field"
    Private _ParentPref As String
#End Region

#Region "Properties"
    Public Property IsDirty() As Boolean
        Get
            Return _IsDirty
        End Get
        Set(ByVal value As Boolean)
            _IsDirty = value
        End Set
    End Property
    Protected ReadOnly Property Parent() As Object Implements IObjectName.Parent
        Get
            Return _Parent
        End Get
    End Property
    Public Sub SetParent(ByVal ParentObject As Object) Implements IObjectName.SetParent
        _Parent = ParentObject
    End Sub
    <Browsable(False)> _
    Public Property ParentPref() As String
        Get
            Return _ParentPref
        End Get
        Set(ByVal value As String)
            _ParentPref = value
        End Set
    End Property
    Public ReadOnly Property ObjectName() As String Implements IObjectName.ObjectName
        Get
            Return _ParentPref
        End Get
    End Property
    Protected Overrides Function GetKeyForItem(ByVal item As EnumValue) As String
        Return item.Value
    End Function
#End Region

#Region "Methods"
    Public Sub SetDirty()
        If Me.Parent IsNot Nothing Then Me.Parent.SetDirty()
    End Sub
    Protected Overrides Sub InsertItem(ByVal index As Integer, ByVal item As EnumValue)
        MyBase.InsertItem(index, item)
        item.SetParent(Me)
    End Sub
    ''' <summary>
    ''' Add emum to collection
    ''' </summary>
    ''' <param name="display_value">Value that is seen</param>
    ''' <param name="value"></param>
    ''' <remarks></remarks>
    Public Shadows Sub Add(ByVal display_value As String, ByVal value As String)
        Me.Add(New EnumValue(display_value, value))
    End Sub
    Public Shadows Sub Add(ByVal o_Enum As EnumValue)
        o_Enum.SetParent(Me)
        MyBase.Add(o_Enum)
    End Sub
#End Region

    
End Class